﻿Imports System.Collections.Generic

Public Class BERankeado
    Private strCPF As String
    Private strIdRanking As String
    Private lstMensagens As List(Of BEMensagem)
    Private objBEUsuario As BE.BEUsuario
  Private strFranquia As String
  Private intPontos As Integer

  Sub New()

  End Sub

  Sub New(ByVal strIdRanking As String, ByVal objBEUsuario As BE.BEUsuario)
    Me.IdRanking = strIdRanking
    Me.Usuario = objBEUsuario
    Me.CPF = objBEUsuario.Cpf
  End Sub

  Public Property IdRanking() As String
    Get
      Return strIdRanking
    End Get
    Set(ByVal value As String)
      strIdRanking = value
    End Set
  End Property

  Public Property Pontos() As Integer
    Get
      Return intPontos
    End Get
    Set(ByVal value As Integer)
      intPontos = value
    End Set
  End Property

  Public Property Franquia() As String
    Get
      Return strFranquia
    End Get
    Set(ByVal value As String)
      strFranquia = value
    End Set
  End Property

    Public Property CPF() As String
        Get
            Return strCPF
        End Get
        Set(ByVal value As String)
            If Not value.Contains(".") And value <> "" Then
                Dim strCPFFormatado As String = ""
                strCPFFormatado &= value.Substring(0, 3)
                strCPFFormatado &= "."
                strCPFFormatado &= value.Substring(3, 3)
                strCPFFormatado &= "."
                strCPFFormatado &= value.Substring(6, 3)
                strCPFFormatado &= "-"
                strCPFFormatado &= value.Substring(9, 2)
                strCPF = strCPFFormatado
            Else
                strCPF = value
            End If

        End Set
    End Property

    Public Property Mensagens() As List(Of BEMensagem)
        Get
            Return lstMensagens
        End Get
        Set(ByVal value As List(Of BEMensagem))
            lstMensagens = value
        End Set
    End Property

    Public ReadOnly Property Nome() As String
        Get
            Return objBEUsuario.Nome
        End Get
    End Property

    Public Property Usuario() As BE.BEUsuario
        Get
            Return objBEUsuario
        End Get
        Set(ByVal value As BE.BEUsuario)
            objBEUsuario = value
        End Set
    End Property

    Public Shared Function Comparador(ByVal objBERankeado1 As BE.BERankeado, ByVal objBERankeado2 As BE.BERankeado) As Integer
        Return objBERankeado2.Pontos.CompareTo(objBERankeado1.Pontos)
    End Function

End Class
